//
//  UIButton+Extension.swift
//  mySinaBlog
//
//  Created by whtapple on 3/27/16.
//  Copyright © 2016 whtapple. All rights reserved.
//

import UIKit

extension UIButton {
    convenience init(title: String, imageName: String, bkgImageName: String = "timeline_card_bottom_background", textColor: UIColor = UIColor.lightGrayColor(), textFont: CGFloat = smallfontsize) {
        self.init()
        
        // 设置
        self.setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        self.setBackgroundImage(UIImage(named: "\(bkgImageName)_highlighted"), forState: UIControlState.Highlighted)
        
        self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(textColor, forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(textFont)
    }
}